<template>
  <a-modal
    :title="title"
    :width="500"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
     
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="出库数量"
          hasFeedback >
          <a-input placeholder="请填写出库数量" v-decorator="['outstorageNumber', {}]" />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="库存数量"
          hasFeedback >
          <a-input  v-model="sumCount"  disabled="disabled"/>
        </a-form-item>
  

    <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="备注"
          hasFeedback >
         <a-textarea placeholder="请输入备注" v-decorator="['remark', {}]" rows="8" style="float: left;"/>
        </a-form-item>

 
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
  import { httpAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import moment from "moment"
 import JImageUpload from '../../../components/jeecg/JImageUpload'
  export default {
    name: "addchukumingxi",
     components: {
      JImageUpload
    },
    data () {
      return {
		  batchCode:'',
		  goodsType:0,
		  outstorageGoodsId:'',
		  id:'',
		  goodsId:'',
		  sumCount:'',
         fileList: [],
        supplierId:'',
        pingzheng:'',
        userId:'',
        title:"操作",
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },

        confirmLoading: false,
        form: this.$form.createForm(this),
        validatorRules:{
        },
        url: {
          add: "/ChukuManager/addchukumingxi",
          edit: "/ChukuManager/addchukumingxi",
        },
      }
    },
    created () {
    },
    methods: {
  
      add () {
        this.edit({});
      },
      edit (record) {
		  
          this.sumCount=record.newCount;
          this.goodsId=record.goodsId;
		    this.id=record.id;
			   this.outstorageGoodsId=record.outstorageGoodsId;
	    this.goodsType=record.goodsType;
	  this.batchCode=record.batchCode;            
	  
        this.form.resetFields();
        //this.model = Object.assign({}, record);
        this.visible = true;
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model,'name','keyWord','sex','age','email','content'))
		      //时间格式化
        //时间格式化
        this.form.setFieldsValue({punchTime:this.model.punchTime?moment(this.model.punchTime,'YYYY-MM-DD HH:mm:ss'):null})
        this.form.setFieldsValue({birthday:this.model.birthday?moment(this.model.birthday):null})
        });

      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'post';
            }
            let formData = Object.assign(this.model, values);


        
            formData['id']=this.id;
            formData['goodsId']=this.goodsId;
             formData['remark']=this.remark;
			   formData['outstorageGoodsId']=this.outstorageGoodsId;
	      formData['goodsType']=this.goodsType;
		
		  formData['batchCode']=this.batchCode;
		
            httpAction(httpurl,formData,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('aaa');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })



          }
        })
      },
      handleCancel () {
        this.close()
      },


    }
  }
</script>

<style scoped>

</style>